package com.yixin.hospital.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yixin.hospital.common.ApiResult;
import com.yixin.hospital.entity.domain.Supplier;
import com.yixin.hospital.entity.dto.req.supplier.SupplierAddReqDTO;
import com.yixin.hospital.entity.dto.req.supplier.SupplierEditReqDTO;
import com.yixin.hospital.service.SupplierService;
import com.yixin.hospital.mapper.SupplierMapper;
import org.springframework.stereotype.Service;

/**
* @author Administrator
* @description 针对表【supplier(供应商表)】的数据库操作Service实现
* @createDate 2024-04-15 14:13:39
*/
@Service
public class SupplierServiceImpl extends ServiceImpl<SupplierMapper, Supplier>
    implements SupplierService{

    @Override
    public ApiResult add(SupplierAddReqDTO supplierAddReqDTO, String userName) {
        Supplier supplier = new Supplier();
        supplier.setName(supplierAddReqDTO.getName());
        supplier.setContactName(supplierAddReqDTO.getContactName());
        supplier.setContactPhone(supplierAddReqDTO.getContactPhone());
        supplier.setCreatedBy(userName);
        supplier.setUpdatedBy(userName);
        this.save(supplier);
        return ApiResult.success();
    }

    @Override
    public ApiResult edit(SupplierEditReqDTO supplierEditReqDTO, String userName) {
        Supplier supplier = new Supplier();
        supplier.setId(supplierEditReqDTO.getId());
        supplier.setName(supplierEditReqDTO.getName());
        supplier.setContactName(supplierEditReqDTO.getContactName());
        supplier.setContactPhone(supplierEditReqDTO.getContactPhone());
        supplier.setUpdatedBy(userName);
        this.updateById(supplier);
        return ApiResult.success();
    }
}




